
\chapter{Future work}

\label{chapter:future}

This appendix catalogs some ideas about {\bf T}'s future development.
It is provided as a stimulus for user input, and as an assurance
that these problems are known and are being addressed.

\section{Language design problems}


A system for managing multiple namespaces - loading files into
appropriate environments, and communicating names from one
module to another in a controlled way - is sorely needed.

Better aggregate structures are needed (arrays, hash tables).

A condition/error signalling system is needed.

Each special form should be marked as being either primitive or a
macro.  This would allow users to write robust program-manipulating
programs using only the released language.

There should be a way to remove bindings from locales.

There ought to be able to have variables named by objects other than
symbols.  Maybe there ought to be a generalized {\tt INTERN} which
creates a unique instance of any object, or something like OWL's
{\tt UCONS} (unique cons) primitive.

Should reintroduce {\tt DEFINE-LOCALE}?

{\tt MEMQ}, {\tt ASSQ}, {\tt POSQ}, etc. are inconsistent with the other
aggregate accessing routines in that the aggregate argument follows the
index argument and not vice versa.

Ideas for list routines: {\tt SUBSET}, {\tt FILTER}, {\tt FIND},
set operations.

Need a term more specific than ``tree'' for whatever those things are.

The tree manipulation routines (e.g. {\tt ALIKEV?}) should be
user-extensible.  Big problem with what {\tt TREE-HASH} should do with
unusual leaf nodes.

There should be a general way to do generic dispatches based on more
than one argument.

There should be a non-side-effecting way to define methods for structures.

{\tt SYNONYM} is a misleading name.

{\tt SETTER} is inadequate.  Why not {\tt PUSHER}, {\tt SWAPPER},
etc.?  Is there any way to do this that's at the same time convenient,
general, and efficient?

{\tt CASE} and {\tt SELECT} should use {\tt EQUIV?} instead of {\tt EQ?}.

Method-clauses aren't incrementally redefinable.  What to do about this.
Objects handling many operations become quite unmanageable.
Maybe this is an implementation and editor problem, not a language problem.

The looping/iteration constructs are maybe a little too simple.  Figure
out some better ones without compromising principles, if possible.
Waters' {\tt LetS} looks sort of good.

{\tt CHECK-ARG} is ad hoc.  Need type inference and other compiler smarts.
Need better type declaration syntax.

There should be case-ignoring character and string comparison predicates.

{\tt STRING-POSQ} is not a good name.

{\tt STRING-REPLACE} should probably be called {\tt STRING-REPLACE!},
or flushed.  Similarly with {\tt VECTOR-FILL}, {\tt VECTOR-REPLACE}.

The name {\tt DIGIT?} is nconsistent with {\tt DIGIT->CHAR} -
does the term {\it digit\/} mean a character or an integer?

What about {\tt UPPERCASE?} $\longrightarrow$\  {\tt UPPER-CASE?}?  Ugh.

Enumerated types.

Infinities?

Should {\tt NOT-ZERO?} and friends be renamed to be {\tt NONZERO?} etc.?

Divulge expression syntax for quasiquote?

Maybe release {\tt BOUND?}.

Need a way to make read tables be read-only.

Need {\tt LET-SYNTAX-TABLE} and {\tt LET-READ-TABLE} features?

Maybe flush the random not-parsable-as-number-implies-symbol syntax feature.
It can be a real pain to catch typos in numbers.

I/O system improvements needed:
\begin{itemize}
\item[{}]Streams are pretty random.  How does a stream differ from a sequence?
There should be ways to coerce from streams to (infinite) sequences,
and vice versa.  Maybe the term {\it stream\/} should follow Sussman's usage
(infinte sequence), not Common Lisp's (pointer into same).

\item[{}]The {\tt FORMAT} sublanguage is random and unextensible.

\item[{}]Block-mode and/or ``binary'' I/O, for database or whatever applications.

\item[{}]There ought to be a way to make the printer complain if it comes
across an object which isn't re-readable.

\item[{}]Ought to be a way to establish the line-length of a stream.

\item[{}]{\tt HPOS} and {\tt VPOS} aren't precisely defined.

\item[{}]{\tt SPACE} operation needs a better definition.
\end{itemize}

Structure package improvements needed:
\begin{itemize}
\item[{}]{\tt DEFINE-STRUCTURE-TYPE} features: initializers, variant record types,
arguments to constructor procedure, type-restricted fields, alternate
name construction.

\item[{}]Maybe structures should have an official external syntax.

\item[{}]Structures ought to be callable.

\item[{}]{\tt COPY-STRUCTURE} and {\tt COPY-STRUCTURE!} ought to take as an
additional argument the structure type to which the structure belongs.
Alternatively, a copying procedure could be associated with the
structure type object itself.

\item[{}]Maybe there ought to be a way to test initializedness of structure components.
\end{itemize}

\section{Common Lisp influence}


The design and implementation of {\bf T} began around the same time that
the Common Lisp design effort started in earnest.  Some of the goals
of the projects have been similar; in many cases, the {\bf T} designers
left certain problems for the Common Lisp designers to work out,
intentionally ignoring many sticky issues, such as numeric routines,
sequences, and arrays, in order to work on other areas.

Now that the Common Lisp language has matured, and portable
implementations are approaching reality, two distinct integration
projects are in order: importing ideas and facilities from Common
Lisp into {\bf T} (with appropriate customization); and building a
Common Lisp emulation package in {\bf T}.

{\bf T} itself will never contain Common Lisp as a subset, but it should be
suitable as an implementation language for a Common Lisp.
This will probably take the form of alternate evaluator, reader, printer,
and namespace, together with a Common Lisp-to-{\bf T} translator.

The following Common Lisp features, at least, should be incorporated
into {\bf T} in some form:
\begin{itemize}
\item[{}]  Arrays.

\item[{}]  Sequences.  (These would clean up a lot of the current clutter with the
  string and vector routines, but introduce a new level of implementation
  hair.)

\item[{}]  Multiple values.  These can be simulated now with continuation-passing,
  but the syntax is clumsy.

\item[{}]  Numeric routines.  Ratios and complexes.
  Multiple floating point precisions.

\item[{}]  {\tt SHIFTF} and {\tt ROTATEF}.  (These are generalized versions of {\bf T}
  {\tt SWAP} and {\tt EXCHANGE}.)

\item[{}]  Hash tables.

\item[{}]  {\tt FORMAT} enhancements: floating-point formats, etc.

\item[{}]  File dates.  Time and date manipulation.  Time and date parsing.
\end{itemize}

\section{Bugs in the implementation}

\label{section:bugs}

This implementation ({\bf T3.1}) doesn't implement everything described
in this manual.

\begin{itemize}
\item[{}]    Not implemented:
    {\tt ATAN2},
    {\tt ROUND},
    {\tt PORT-POSITION},
    and {\tt TRUNCATE}.
\end{itemize}

Many things are implemented incorrectly.

\begin{itemize}
\item[{}]    Deficiencies in syntax environments (they don't exist per se) and in
    locales (shadowing loses).

\item[{}]    {\tt GENERATE-SYMBOL}:  The implementation generates obscure
    names, but doesn't
    guarantee uniqueness.  That is, the symbols are interned.

\item[{}]    {\tt ANY?} and {\tt EVERY?} of more than one list don't work.

\item[{}]    {\tt GET} and {\tt PUT} work only on symbols.

\item[{}]    {\tt READ-LINE} and {\tt UNREAD-CHAR} interact badly.

\item[{}]    There is no way to trace an operation.
\end{itemize}

Many things are implemented less efficiently than they ought to be.

\begin{itemize}
\item[{}]    The garbage collector is slow.  This should be fixed.

\item[{}]    There ought to be an option to invoke the standard compiler on
    demand, as code is run, instead of all at once, as code is loaded.

\item[{}]    {\tt BIND} is implemented in a pretty cons-intensive way;
    there's a bigger performance penalty for dynamic binding than one would
    find in other Lisp implementations.

\item[{}]    ``Lexprs'' are inefficient because they always cons a list for the
    rest-variable.

\item[{}]    The i/o system doesn't do any buffering; this really slows down
    reading and printing a lot, most notably the loading of code files.

\item[{}]    Operation dispatch could be done using hash tables.  {\tt DEFINE-OPERATION}
    needs to do early binding.  This is feasible, but the implementation
    could become quite hairy.

\item[{}]    Locales are permanent (!), and forward references to shadowed variables
    will lose big, especially with the standard compiler.

\item[{}]    The interpreter conses a lot more than it ought to.  It ought to do some
    small amount of closure analysis, or else use McDermott's dynamic
    migration hack.

\item[{}]    The combinator routines are pretty useless since TC doesn't know
    anything about them.  This should be fixed.  For example,
    {\tt ((COMPOSE CAR CDR) (A B C)}') is evaluated, even in compiled code,
    by actually consing a procedure, and then invoking it.
\end{itemize}

Many things in the system are implemented less smoothly than they ought to be.

\begin{itemize}
\item[{}]    Many system routines still don't check their argument types.

\item[{}]    Redefining {\tt DEFINE-CONSTANT}'ed and {\tt DEFINE-INTEGRABLE}'d
    should report an error condition.

\item[{}]    Newline characters following input lines come out at the wrong place
    in transcript files.

\item[{}]    {\tt LOAD} ought to be smarter about file dates, checking for
    recompilation, etc.

\item[{}]    Interpreted {\tt QUOTE} ought to enforce read-only-ness.

\item[{}]    There ought to be a way to enforce the downwards-only-ness of escape
    procedures.
\end{itemize}

Missing features.

\begin{itemize}

\item[{}]    Help system.

\item[{}]    More system self-knowledge: who calls x, who does x call, type analysis,
    etc.  Masterscope-like stuff.

\item[{}]    There should be a version of {\tt TRACE} which {\it destructively\/}
    modifies a procedure so that it acts traced.

\end{itemize}
